*** Set working directory ***
cd "C:\..."

*********************** Load Data **********************************************
clear
graph drop _all
cap drop all

import excel "High_Frequency.xlsx", sheet("financial") firstrow

gen monthly_date = mofd(date)
format monthly_date %tm
sort monthly_date
save financial, replace

***
clear
import excel "High_Frequency.xlsx", sheet("gscpi") firstrow
gen monthly_date = mofd(month)
format monthly_date %tm
sort monthly_date
drop month

merge 1:m monthly_date using financial
drop if _merge != 3
drop _merge

*******************************
* Normalize GSCPI for 1998-2019 sample
rename gscpi gscpi_unscl
egen gscpi_mean = mean(gscpi_unscl)
gen gscpi_dm = gscpi_unscl - gscpi_mean
egen gscpi_std = sd(gscpi_dm)
gen gscpi = gscpi_dm/gscpi_std

* Time Variables
egen time = group(date)
tsset time
gen year = year(date)

* MP GSCPI Interaction 
gen mp_gspci = mps*L.gscpi

************************ Table 3 Regressions************************************
* Full Sample:
reg stk mps L.gscpi mp_gspci if year != 2008, vce(robust)
outreg2 using "table3a.xml", replace se bdec(3) bracket label 
reg tp2y mps L.gscpi mp_gspci if year != 2008, vce(robust)
outreg2 using "table3a.xml", append se bdec(3) bracket label 
reg tp10y mps L.gscpi mp_gspci if year != 2008, vce(robust)
outreg2 using "table3a.xml", append se bdec(3) bracket label 

* Post-Crisis:
reg stk mps L.gscpi mp_gspci if year > 2008, vce(robust)
outreg2 using "table3b.xml", replace se bdec(3) bracket label 
reg tp2y mps L.gscpi mp_gspci if year > 2008, vce(robust)
outreg2 using "table3b.xml", append se bdec(3) bracket label 
reg tp10y mps L.gscpi mp_gspci if year > 2008, vce(robust)
outreg2 using "table3b.xml", append se bdec(3) bracket label 


********************************************************************************